#!/usr/bin/env python3
# coding:utf-8

import time
import serial
import debugpy

class Chassis_smd:
    def __init__(self,name,bps):
        self.serial = serial.Serial(name, bps, timeout=2)
        if self.serial.isOpen():
            print("Serial open ",self.serial.name)
        else:
            print("Serial error")
            raise Exception("serial 苏美d底盘打开失败")

# 更简洁的写法
if __name__ == "__main__":
    serial_name = '/dev/ttyChaisses'
    bps = 115200
    ser = Chassis_smd(serial_name,bps)
    # debugpy.listen(6688)
    while True:
        data = ""
        try:
            if ser.serial.in_waiting:
                data = ser.serial.read(ser.serial.in_waiting)
                print("data len",len(data))
            time.sleep(0.02)
        except Exception as e:
            print(e)
            time.sleep(2)

'''

'''
